/**
 * @description seed-submit-button
 * @author ouxh-862
 * @date 2017-11-8
 *
 *   页面使用需要给 seed-submit-button 加上宽度，若需要固定点到底部请自行添加定位。
 * @Input:
 *  btnText: string ; 按钮中的文字
 *  disabled : boolean; 按钮的失效状态
 *  hasLeftBtn: boolean; 是否有左边按钮 （适用于当有两个并排的按钮时）
 *  leftDisabled : boolean; 左边按钮的失效状态
 *  leftBtnText : string; 左边按钮的文字
 * @Output:
 *  submit:true; 点击按钮
 *  onLeftBtnClick:true; 点击左边按钮（有两个按钮时）
 *
 */
import {Component, OnInit, ViewEncapsulation, Input, EventEmitter, Output} from '@angular/core';

@Component({
  selector: 'seed-submit-button',
  templateUrl: './submit-button.component.html',
  styleUrls: ['./submit-button.component.scss'],
  encapsulation: ViewEncapsulation.None
})
export class SubmitButtonComponent implements OnInit {

  public visiable = true;
  private _btnText: string;
  private _leftBtnText: string;

  @Input() disabled: boolean;
  @Input() leftDisabled: boolean;

  @Input() hasLeftBtn: boolean;

  @Input()
  set btnText(val) {
    this._btnText = val;
  }

  get btnText() {
    return this._btnText;
  }

  @Input()
  set leftBtnText(val) {
    this._leftBtnText = val;
  }

  get leftBtnText() {
    return this._leftBtnText;
  }

  @Output() submit: EventEmitter<any> = new EventEmitter();
  @Output() onLeftBtnClick: EventEmitter<any> = new EventEmitter();

  constructor() {
    this.btnText = '添加';
    this.leftBtnText = '删除';
  }

  ngOnInit() {

  }

  hide() {
    this.visiable = false;
  }

  show() {
    this.visiable = true;
  }

  del() {
    this.onLeftBtnClick.emit(true);
  }

  sub() {
    this.submit.emit(true);
  }
}
